import { lazy } from 'react'
import { Navigate } from 'react-router-dom'
import Publish from '../Cao/Publish.tsx';
const Layout = lazy(() => import('../views/layout'))
const Home = lazy(() => import('../views/home'))
const Caochang = lazy(() => import('../views/Caochang'))
const Login = lazy(() => import('../views/Login'))
const Xiaoxi = lazy(() => import('../views/Xiaoxi'))

const Chat = lazy(() => import('../views/Chat'))
const GroupChat = lazy(() => import('../views/GroupChat'))

const My = lazy(() => import('../may/My'))
const NotFound = lazy(() => import('../views/notFound'))
const ConfessionWall = lazy(() => import('../Cao/ConfessionWall.tsx'))
const DongtaiDetail = lazy(() => import('../Cao/DongtaiDetail.tsx'))
const VipRecharge = lazy(() => import('../Cao/VipRecharge.tsx'))
// 添加TopicSquare组件的懒加载导入
const TopicSquare = lazy(() => import('../Cao/TopicSquare.tsx'))
const TopicDetail = lazy(() => import('../Cao/topicdetail.tsx'))
const UserDetail = lazy(() => import('../Cao/UserDetail.tsx'))
const Guide = lazy(() => import('../zkd/Guide'))
const Chooseschool = lazy(() => import('../zkd/Chooseschool'))
const Mediapipe = lazy(() => import('../may/mediapipe_test'))
const Ocr = lazy(() => import('../may/test-ocr'))
const Register = lazy(() => import('../zkd/Register'))
const Myprivacy = lazy(() => import('../zkd/Myprivacy'))
const Renlian = lazy(() => import('../zkd/Renlian'))
const Emaillogin = lazy(() => import('../zkd/Emaillogin'))
const Renlianlogin = lazy(() => import('../zkd/Renlianlogin'))
const SetGesture = lazy(() => import('../zkd/SetGesture'))
const LoginGesture = lazy(() => import('../zkd/LoginGesture'))
const ChangeName = lazy(() => import('../zkd/ChangeName'))
const Changeqianming = lazy(() => import('../zkd/Changeqianming'))

// Yang文件夹页面组件懒加载导入
const YangHome = lazy(() => import('../yang/Home'))
const CampusCardBind = lazy(() => import('../yang/CampusCardBind'))
const CampusCardBound = lazy(() => import('../yang/CampusCardBound'))
const CampusCardUnbind = lazy(() => import('../yang/CampusCardUnbind'))
const CardRecharge = lazy(() => import('../yang/CardRecharge'))
const CloudPayment = lazy(() => import('../yang/CloudPayment'))
const PhoneRecharge = lazy(() => import('../yang/PhoneRecharge'))
const TuitionPayment = lazy(() => import('../yang/TuitionPayment'))
const OnlineRepair = lazy(() => import('../yang/OnlineRepair'))
const AllApps = lazy(() => import('../yang/AllApps'))
const SchoolIntro = lazy(() => import('../yang/SchoolIntro'))
const CampusNews = lazy(() => import('../yang/CampusNews'))
const GradeQuery = lazy(() => import('../yang/GradeQuery'))
const CardFAQ = lazy(() => import('../yang/CardFAQ'))
const CourseSchedule = lazy(() => import('../yang/CourseSchedule'))
const UserProfile = lazy(() => import('../yang/UserProfile'))
const PostDetail = lazy(() => import('../yang/PostDetail'))

// 添加AI聊天和二维码扫描组件的懒加载导入
const AIChat = lazy(() => import('../yang/AIChat'))
const QRScanner = lazy(() => import('../yang/QRScanner'))

const routes = [
    {
        path: '/layout', element: <Layout />, children: [
            { path: '/layout/home', element: <YangHome /> }, // 使用Yang的Home组件替换原来的Home
            { path: '/layout/Caochang', element: <Caochang /> },
            { path: '/layout/Xiaoxi', element: <Xiaoxi /> },
            { path: '/layout/My', element: <My /> },
        ]
    },
    { path: '/publish', element: <Publish /> },
    { path: '/confession-wall', element: <ConfessionWall /> },
    { path: '/vip', element: <VipRecharge /> },
    // 添加TopicSquare组件的路由项
    { path: '/topic-square', element: <TopicSquare /> },
    { path: '/topic-detail/:topicId', element: <TopicDetail /> },
    { path: '/login', element: <Login /> },
    { path: '/mtest1', element: <Mediapipe /> },
    { path: '/mtest2', element: <Ocr /> },
    { path: '/guide', element: <Guide /> },
    { path: '/chooseschool', element: <Chooseschool /> },
    { path: '/register', element: <Register /> },
    { path: '/myprivacy', element: <Myprivacy /> },
    { path: '/renlian', element: <Renlian /> },
    { path: '/emaillogin', element: <Emaillogin /> },
    { path: '/renlianlogin', element: <Renlianlogin /> },
    { path: '/set-gesture', element: <SetGesture /> },
    { path: '/login-gesture', element: <LoginGesture /> },
    { path: '/changename', element: <ChangeName /> },
    { path: '/changeqm', element: <Changeqianming /> },
    { path: '/dongtai-detail/:id', element: <DongtaiDetail /> }, // 动态详情页面路由
    { path: '/user-detail/:userId', element: <UserDetail /> }, // 用户详情页面路由
    // Yang文件夹页面路由配置
    { path: '/yang-home', element: <YangHome /> }, // 独立的Yang首页路由
    { path: '/campus-card-bind', element: <CampusCardBind /> }, // 校园卡绑定
    { path: '/campus-card-bound', element: <CampusCardBound /> }, // 校园卡已绑定状态
    { path: '/campus-card-unbind', element: <CampusCardUnbind /> }, // 校园卡未绑定状态
    { path: '/card-recharge', element: <CardRecharge /> }, // 饭卡充值
    { path: '/cloud-payment', element: <CloudPayment /> }, // 云缴费
    { path: '/phone-recharge', element: <PhoneRecharge /> }, // 话费充值
    { path: '/tuition-payment', element: <TuitionPayment /> }, // 学费缴纳
    { path: '/online-repair', element: <OnlineRepair /> }, // 在线报修
    { path: '/all-apps', element: <AllApps /> }, // 全部应用
    { path: '/school-intro', element: <SchoolIntro /> }, // 学校介绍
    { path: '/campus-news', element: <CampusNews /> }, // 校内新闻
    { path: '/grade-query', element: <GradeQuery /> }, // 成绩查询
    { path: '/card-faq', element: <CardFAQ /> }, // 校园卡常见问题
    { path: '/course-schedule', element: <CourseSchedule /> }, // 课程表
        { path: '/user-profile/:userId', element: <UserProfile /> }, // 用户详情页面
    { path: '/post-detail/:postId', element: <PostDetail /> }, // 动态详情页面
    
    // AI工具和扫一扫路由
    { path: '/ai-chat', element: <AIChat /> }, // AI智能助手
    { path: '/qr-scanner', element: <QRScanner /> }, // 扫一扫
    
    // 消息相关路由（保留Xiaoxi组件）
    { path: '/xiaoxi', element: <Xiaoxi /> },

    // 聊天相关路由
    { path: '/xiaoxi', element: <Xiaoxi /> },
    { path: '/chat/new/:receiverId', element: <Chat /> },
    { path: '/chat/:conversationId/:receiverId', element: <Chat /> },

    // 群聊相关路由
    { path: '/group/:groupId', element: <GroupChat /> },

    { path: '/', element: <Navigate to="/guide" replace /> },
    { path: '*', element: <NotFound /> },
]
console.log("🚀 ~ 所有路由=>", routes)
export default routes